1 kilometer is equal to 0.621371 miles.
def kilometers_to_miles(kilometers):
return kilometers * 0.621371
# Taking input for kilometers and converting them to miles
def convert_and_display_kilometers_to_miles():
kilometers = float(input("Enter the distance in kilometers: "))
miles = kilometers_to_miles(kilometers)
print("Distance in miles:", miles)
convert_and_display_kilometers_to_miles()
Enter the distance in kilometers: 10
Distance in miles: 6.21371
Enter the distance in kilometers: 25
Distance in miles: 15.534275
The function kilometers_to_miles(kilometers)
converts kilometers to miles using the conversion factor.
The function convert_and_display_kilometers_to_miles()
takes input for kilometers, converts them to miles using the aforementioned function, and displays the result.